<template>
  <div class="department-section-pair" :style="{ width: `${width}%` }">
    <div
      class="department-sections"
      v-for="(depart, depairtIndex) in sections"
      :key="depairtIndex"
    >
      <el-carousel
        :interval="interval"
        arrow="never"
        indicator-position="none"
        direction="vertical"
        :pause-on-hover="false"
      >
        <el-carousel-item
          class="department-section"
          v-for="(item, index) in depart"
          :key="index"
        >
          <div class="department-section-dept">{{ item.departName }}</div>
          <div class="department-section-data">
            <div
              v-for="(doctor, index) in item.employees"
              :key="index"
              class="department-section-data-item"
            >
              <DoctorCard
                :doctor="doctor"
                :index="index"
                :background="
                  depairtIndex % 2 === 0 ? '#d8f9fd' : '#d7fadc'
                "
              />
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script setup>
import DoctorCard from "./DoctorCard.vue";

const props = defineProps({
  sections: {
    type: Array,
    required: true,
    default: () => [
      [
        {
          name: "",
          id: "",
          doctors: [],
        },
      ],
    ],
  },
  width: {
    type: Number,
    default: 100,
  },
  interval: {
    type: Number,
    default: 3000,
  },
});
</script>

<style scoped lang="scss">
.el-carousel {
  width: 100%;
  height: 100%;
  :deep(.el-carousel__container) {
    width: 100%;
    height: 100%;
  }
}
.department-section-pair {
  display: flex;
  flex-direction: column;
  width: auto;
  height: 100%;
  display: flex;
  padding: 0;
  color: #221c59;
  font-size: 0.3rem;
  min-width: 0;
}
.department-sections {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
}
.department-section {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  flex: 1;
  &-dept {
    flex: 0 0 0.8rem;
    background: #fff;
    border-radius: 0.08rem;
    margin: 0.05rem;
    font-size: 0.5rem;
    display: block;
    align-items: center;
    text-align: center;
    justify-content: center;
    padding: 0.05rem;
    overflow: hidden;
    font-weight: bold;
    writing-mode: vertical-lr;
    letter-spacing: 0.05rem;
  }
  &-data {
    flex: auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    &-item {
      width: 4.08rem;
      margin: 0;
      padding: 0.05rem;
    }
  }
}
</style>
